package com.freewater.springboot.demo.aop.api.autoproxy.name;

import com.freewater.springboot.demo.PackageUtils;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;

public class Main {
    public static void main(String[] args) {
        GenericApplicationContext applicationContext = new GenericApplicationContext();
        final String xmlPath = PackageUtils.getDefaultAppContextXmlPath(Main.class);
        new XmlBeanDefinitionReader(applicationContext).loadBeanDefinitions(xmlPath);
        applicationContext.refresh();
        applicationContext.start();
        applicationContext.registerShutdownHook(); // 注册jvm关闭回调，jvm关闭时一并关闭spring容器

        SomeService someService = applicationContext.getBean(SomeService.class);
        someService.doSomething();
        OtherService otherService = applicationContext.getBean(OtherService.class);
        otherService.doOther();
    }
}
